<template>
	<view>
		<view class="msItem" v-for="(item,index) in list" :key="index" @click="goxiangqing(item)">
			<view class="img">
				<u-image width="220rpx" height="220rpx" :src="item.image"></u-image>
			</view>
			<view class="right">
				<view class="name">
					{{item.store_name}}
				</view>
				<view class="xinghao">
					<!-- {{item.xinghao}} -->
				</view>
			</view>
			<view class="daojishi">
				<countdown :startTime="startTime" :endTime="$u.timeFormat(item.end_time, 'yyyy-mm-dd hh:MM:ss')" />
			</view>
			<view class="jiage">
				{{item.price}}
			</view>
			<view class="close" v-if="item.start_time >= Date.parse(new Date())/1000">
				<view class="close_top">
					暂未开始
				</view>
				<view class="time">
					{{item.start_time | date('mm-dd hh:MM')}} - {{item.end_time | date('mm-dd hh:MM')}}
				</view>
			</view>
			<view class="close" v-if="item.end_time <=  Date.parse(new Date())/1000">
				<view class="close_top">
					已结束
				</view>
				<view class="time">
					{{item.start_time | date('mm-dd hh:MM')}} - {{item.end_time | date('mm-dd hh:MM')}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import countdown from "@/components/cz-countdown/cz-countdown.vue"
	export default {
		components: {
			countdown
		},
		data() {
			return {
				list: [],
				startTime: this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd hh:MM:ss'),

			};
		},
		onLoad() {
			this.getshoplist()
		},
		methods: {
			getshoplist() {
				uni.request({
					url: this.$AJAX_URL + 'goods/solitaire_product_list',
					success: (res) => {
						if (res.data.code === 200) {
							this.list = res.data.data
						}
						console.log(res);
						console.log(Date.parse(new Date()) / 1000);
					}
				})
			},
			goxiangqing(item) {
				uni.navigateTo({
					url: '../msxiangqing/msxiangqing?id=' + item.id
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f7f7f7;
	}

	.msItem {
		padding: 20rpx;
		background: #FFFFFF;
		display: flex;
		position: relative;
		width: 100%;
		height: 260rpx;
		margin-top: 10rpx;

		.img {
			width: 220rpx;
			height: 220rpx;
			overflow: hidden;
			border-radius: 20rpx;
		}

		.right {
			margin-left: 20rpx;
			margin-top: 28rpx;

			.name {
				width: 400rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 28rpx;
				color: #000000;
			}

			.xinghao {
				font-size: 24rpx;
				color: #919191;
			}
		}

		.daojishi {
			position: absolute;
			right: 10rpx;
			top: 10rpx;
		}

		.jiage {
			font-size: 38rpx;
			color: #000;
			font-weight: bold;
			position: absolute;
			bottom: 30rpx;
			right: 12rpx;
		}

		.close {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background-color: rgba(0, 0, 0, 0.5);
			z-index: 10;

			.close_top {
				text-align: center;
				font-size: 42rpx;
				color: #FFFFFF;
				margin-top: 75rpx;
			}

			.time {
				text-align: center;
				color: #FFFFFF;
				font-size: 32rpx;
				margin-top: 30rpx;
			}
		}

	}
</style>
